package izzat.fit.action.controller;

        import izzat.fit.action.entity.Action;
        import izzat.fit.action.entity.ResponseEntity;
        import izzat.fit.action.remote.DBRemote;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.web.bind.annotation.*;

        import java.util.List;


/**
 * @ClassName: ActionController
 * @Description:
 * @Author: Izzat
 * @Date: 2019-12-31 19:01
 * @Version: v1.0
 */
@RestController
public class ActionController {

    @Autowired
    DBRemote dbRemote;

    @RequestMapping("hello")
    /**
     * @Description: 测试是否成功调用 db-service 服务
     * @Param: []
     * @return: java.lang.String
     * @Author: Izzat
     * @Date: 2019/12/31  19:12
     */
    public String hello() {
        return dbRemote.hello();
    }

    @RequestMapping("allAction")
    /**
     * @Description: 获取所有动作
     * @Param: []
     * @return: java.lang.String
     * @Author: Izzat
     * @Date: 2019/12/31  19:23
     */
    public ResponseEntity allAction() {
        return dbRemote.allAction();
    }

    @RequestMapping("findById")
    /**
     * @Description: 按找id查找
     * @Param: [id]
     * @return: javax.swing.Action
     * @Author: Izzat
     * @Date: 2019/12/31  23:12
     */
    public ResponseEntity findById(@RequestBody Action id){
        return dbRemote.findById(id.getId());
    }

    @RequestMapping("findByPart")
    /**
     * @Description: 按找锻炼部位找动作
     * @Param: [part]
     * @return: izzat.fit.action.entity.Action
     * @Author: Izzat
     * @Date: 2020/1/1  13:19
     */
    public ResponseEntity findByPart(@RequestBody Action part){
        return dbRemote.findByPart(part.getPart());
    }

    @RequestMapping("addPart")
    /**
    * @Description: 增加一个训练计划
    * @Param: [part]
    * @return: izzat.fit.action.entity.ResponseEntity
    * @Author: Izzat
    * @Date: 2020/3/16  21:43
    */
    public ResponseEntity addPart(@RequestBody Action part){
        return dbRemote.findByPart(part.getPart());
    }
}
